home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 December / december_2000.iso / Intercd / root / Mail / ^MailShield / setup.exe / data1.cab / Default_Rule_Files / begin.mml next >
Encoding:
Text File  |  2000-10-18  |  6.3 KB  |  155 lines

  1. ##############################################################################
  2. # begin.mml 
  3. #
  4. # MailShield script that is run when the SMTP connection begins
  5. #
  6.  
  7. ##############################################################################
  8. # (optional) log this connection
  9. #
  10. #    &LogMessage("SMTP Connection received from: ".$PeerHostname." [".$PeerTcpip."] on ".$MyHostname." [".$MyTcpip."]");
  11.  
  12.  
  13. ##############################################################################
  14. # Check to see if the peer connected to us is listed as approved for relaying
  15. # in which case, we accept the connection and return immediately. We set the 
  16. # $accept variable to TRUE so that some minimal tests are still performed
  17. # on the message (such as slowing down if too many recipients). If you want
  18. # to perform absolutely no more tests on this connection, then change "exit;"
  19. # to "&Accept;"
  20.  
  21.     # check the TCP/IP address to see if ok for relaying.
  22.     if (&IpInArrayRange(@relay_ok_tcpip, $PeerTcpip)) { 
  23.         $accept = TRUE;
  24.         &MessageAppend(" (TCP/IP address approved for relaying)");
  25.         exit;
  26.     }; 
  27.  
  28.     # check the hostname to see if OK for relaying.
  29.     if (index(lc($PeerHostname), @relay_ok_hostnames) > -1) { 
  30.         $accept = TRUE;
  31.         &MessageAppend(" (hostname approved for relaying)");
  32.         exit;
  33.     }; 
  34.  
  35.    
  36. ##############################################################################
  37. # check for banned TCP/IP range
  38.  
  39.     if (scalar(@banned_tcpip) > 0) { 
  40.         if (&IpInArrayRange(@banned_tcpip, $PeerTcpip)) { 
  41.             $smtp_message = "550 Message refused";
  42.             $log_message = "550 Banned SMTP host TCP/IP address: ".$PeerTcpip." / matched ".$match;
  43.             &DefaultRejection;
  44.         };
  45.     };
  46.  
  47. ##############################################################################
  48. # check for banned domain names
  49.  
  50.     if (scalar(@banned_domains) > 0) { 
  51.         if (index(lc($PeerHostname), @banned_domains) > -1) { 
  52.             $smtp_message = "550 Message refused";
  53.             $log_message = "550 Banned SMTP host domain name: ".$PeerHostname." / matched ".$match;
  54.             &DefaultRejection;
  55.         };
  56.     };
  57.     
  58. ##############################################################################
  59. # check to make sure this TCP/IP address has a valid Internet host name
  60.  
  61.     if ($reject_no_hostname) {
  62.         if (length($PeerHostname) == 0) {
  63.             $smtp_message = "550 Connection refused because no reverse DNS found for ".$PeerTcpip;
  64.             $log_message = "550 TCP/IP address: ".$PeerTcpip." does not have a DNS hostname";
  65.             &DefaultRejection;
  66.         };
  67.     };
  68.  
  69.  
  70. ##############################################################################
  71. # Check to see if this TCP/IP address is blacklisted using the RBL+ system
  72.  
  73.     if ($use_rbl_plus) {
  74.         if (&DNSRBLLookup(".rbl-plus.mail-abuse.org", $PeerTcpip)) {
  75.             $log_message = "550 SMTP session refused because your host tested positive on RBL+. See http://mail-abuse.org/rbl+/";
  76.             $smtp_message = "550 TCP/IP address: ".$PeerTcpip." is listed on the RBL+. See http://mail-abuse.org/rbl+/";
  77.         };
  78.     }
  79.  
  80.     # If we are not using rbl+, check for other MAPS services
  81.  
  82.     else {
  83.  
  84.     ##############################################################################
  85.     # Check to see if this TCP/IP address is blacklisted on the
  86.     # Real-time Blackholing System (see http://maps.vix.com/rbl/ for info)
  87.     
  88.         if ($use_rbl) {
  89.             if (&IsOnRbl($PeerTcpip)) { 
  90.                 $log_message = "550 SMTP session refused because your host is listed on the RBL. See http://maps.vix.com/rbl/";
  91.                 $smtp_message = "550 TCP/IP address: ".$PeerTcpip." is listed on the RBL. See http://maps.vix.com/rbl/";
  92.                 &DefaultRejection;
  93.             };
  94.         };
  95.     
  96.     ##############################################################################
  97.     # Check to see if this TCP/IP address is blacklisted on the
  98.     # MAPS Relay Spam Stopper (RSS) (see http://www.mail-abuse.org/rss/ for info)
  99.     
  100.         if ($use_rss) {
  101.             if (&DNSRBLLookup(".relays.mail-abuse.org", $PeerTcpip)) { 
  102.                 $log_message = "550 SMTP session refused because your host is listed on the RSS. See http://www.mail-abuse.org/rss/";
  103.                 $smtp_message = "550 TCP/IP address: ".$PeerTcpip." is listed on the RSS. See http://www.mail-abuse.org/rss/";
  104.                 &DefaultRejection;
  105.             };
  106.         };
  107.     
  108.     ##############################################################################
  109.     # Check to see if this TCP/IP address is blacklisted on the
  110.     # MAPS DUL (see http://maps.vix.com/dul/ for info)
  111.     
  112.         if ($use_dul) {
  113.             if (&DNSRBLLookup(".dialups.mail-abuse.org", $PeerTcpip)) { 
  114.                 $log_message = "550 SMTP session refused because your host is listed on the DUL. See http://mail-abuse.org/dul/";
  115.                 $smtp_message = "550 TCP/IP address: ".$PeerTcpip." is listed on the DUL. See http://mail-abuse.org/dul/";
  116.                 &DefaultRejection;
  117.             };
  118.         };
  119.  
  120.     }; 
  121.  
  122. ##############################################################################
  123. # Check to see if this TCP/IP address is blacklisted on the
  124. # Open Relay Blocking System (ORBS) (see http://www.orbs.org for info)
  125.  
  126.     if ($use_orbs) {
  127.         if (&DNSRBLLookup(".relays.orbs.org", $PeerTcpip)) { 
  128.             $log_message = "550 SMTP session refused because your host is listed on the ORBS. See http://www.orbs.org";
  129.             $smtp_message = "550 TCP/IP address: ".$PeerTcpip." is listed on the ORBS. See http://www.orbs.org";
  130.             &DefaultRejection;
  131.         };
  132.     };
  133.  
  134. ##############################################################################
  135. # check for tarpitted TCP/IP range
  136.  
  137.     if (scalar(@tarpit_addresses) > 0) { 
  138.         if (&IpInArrayRange(@tarpit_addresses, $PeerTcpip)) { 
  139.             $tarpit = TRUE;
  140.             sleep($tarpit_delay);
  141.         };
  142.     };
  143.  
  144. ##############################################################################
  145. # check for tarpitted domain names
  146.  
  147.     if (scalar(@tarpit_hostnames) > 0) { 
  148.         if (index(lc($PeerHostname), @tarpit_hostnames) > -1) { 
  149.             $tarpit = TRUE;
  150.             sleep($tarpit_delay);
  151.         };
  152.     };
  153.     
  154.  
  155.